<?php
namespace Admin\Controller;
use Think\Controller;
class AnonymousController extends CommonController 
{
	//免注册需求管理
	//匿名家长需求列表
    public function index()
    {
    	$nm_list = M('zhao_laoshi')->where('is_shaixuan=0')->select();
    	$this->assign('nm_list',$nm_list);

        $this->display();
    }


    /**
     * 导出 匿名家长需求表所有数据
     */
    public function anonymous_export(){
        $nm_list = M('zhao_laoshi')->select();

        $subject="Excel导出-无注册家长需求表";
        $title=array("id","姓名","年级","科目","上课地址","手机号码","所在城市","提交时间","筛选状态","处理状态","备注");
        exportExcel($nm_list,$title,$subject); 
    }



    //批量删除
    public function deletes()
    {
      //print_r($_POST);exit;
      //Array ( [arr] => Array ( [0] => 1 [1] => 2 ) )
      if (IS_POST) {
        $arr = I('post.arr');
        $ids = implode(",", $arr);

        $res = M('zhao_laoshi')->delete($ids);
          if ($res) {
              $arr = array(
                  'error' =>0,
                  'info'=>"删除成功"
                  );
              echo json_encode($arr);
          }else {
              $arr = array(
                  'error' =>1,
                  'info'=>"删除失败"
                  );
              echo json_encode($arr);
          }
      }
    }
 
    //is_shaixuan 客服筛选状态改1 0为筛选 1筛选
    public function is_shaixuan()
    {
      if (IS_POST) {
        $id = I('post.id');
        $res = M('zhao_laoshi')->where(array('id'=>$id))->setField('is_shaixuan',1);
          if ($res) {
              $arr = array(
                  'error' =>0,
                  'info'=>"提交到筛选列表"
                  );
              echo json_encode($arr);
          }else {
              $arr = array(
                  'error' =>1,
                  'info'=>"提交失败"
                  );
              echo json_encode($arr);
          }
      }
    }

	//已筛选待处理列表
    public function shaixuan()
    {
    	$nm_list = M('zhao_laoshi')->where('is_shaixuan=1 and is_ok=0')->select();
    	$this->assign('nm_list',$nm_list);

        $this->display();
    }

    //is_ok 处理状态改1 0为未处理 1处理
    public function is_ok()
    {
      if (IS_POST) {
        $id = I('post.id');
        $res = M('zhao_laoshi')->where(array('id'=>$id))->setField('is_ok',1);
          if ($res) {
              $arr = array(
                  'error' =>0,
                  'info'=>"处理成功"
                  );
              echo json_encode($arr);
          }else {
              $arr = array(
                  'error' =>1,
                  'info'=>"处理失败"
                  );
              echo json_encode($arr);
          }
      }
    }

	//已处理列表
    public function ok()
    {
    	$nm_list = M('zhao_laoshi')->where('is_ok=1')->select();
    	$this->assign('nm_list',$nm_list);

        $this->display();
    }
}